package ModelLayer;


/**
 * Vestbjerg project
 * @GroupB2 (UCN - Computer Science DMAJ0914) 
 */
public abstract class Item implements Comparable<Item>
{
    // instance variables
    private String barcode;
    private String name;
    private String description;
    private double price;
    private int amountSold;
    
    /**
     * Constructor for objects of class Item
     */
    public Item(String barcode, String name, String description, double price)
    {
        this.barcode = barcode;
        this.name = name;
        this.description = description;
        this.price = price;
        this.amountSold = 0;
    }
    
    public void setBarcode(String barcode)
    {
        this.barcode = barcode;
    }
    
    public void setName(String name)
    {
        this.name = name;
    }
    
    public void setDescription(String description)
    {
        this.description = description;
    }
    
    public void setPrice(double price)
    {
        this.price = price;
    }
        
    public String getBarcode()
    {
        return barcode;
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getDescription()
    {
        return description;
    }
    
    public double getPrice()
    {
        return price;
    }
    
    public int getAmountSold() 
    {
        return amountSold;
    }
    
    public void updateAmountSold(int amount) 
    {
        this.amountSold += amount;
    }
    
    public int compareTo(Item item) 
    {
        if(getAmountSold() < item.getAmountSold()) 
        {
            return 1;
        }
        else 
        {
            if(getAmountSold() == item.getAmountSold()) 
            {
                return 0;
            }
            else 
            {
                return -1;
            }
        }
    }
}
